using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using Entities;
using Utility;
namespace BUS
{
   public class tbDattourBUS
    {
        public static void Insert(tbDattour dt)
        {
            tbDattourDAL dtDAL = new tbDattourDAL();
            dtDAL.Insert(dt);
        }
        public static void Update(tbDattour dt)
        {
            tbDattourDAL dtDAL = new tbDattourDAL();
            dtDAL.Update(dt);
        }
        public static void Delete(int iD)
        {
            tbDattourDAL dtDAL = new tbDattourDAL();
            dtDAL.Delete(iD);
        }
        public static tbDattourCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbDattourDAL dtDAL = new tbDattourDAL();
            return dtDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbDattourCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbDattourDAL dtDAL = new tbDattourDAL();
            return dtDAL.Get(cri.Criter, 0, 0, tbDattourColloumn.madattour.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbDattour GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbDattourColloumn.madattour.ToString(), Condition.EQUAL, iD);
            tbDattourDAL dtDAL = new tbDattourDAL();
            tbDattourCollection dtColl= dtDAL.Get(cri.Criter, 0, 0, tbDattourColloumn.madattour.ToString(), OrderDirection.ASC.ToString(), out total);
            if (dtColl.Count > 0)
                return dtColl[0];
            return null;
        }
        public static tbDattourCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbDattourDAL dtDAL = new tbDattourDAL();
            return dtDAL.Get(cri.Criter, 1, number,
            tbDattourColloumn.madattour.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbDattourCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbDattourDAL dtDAL = new tbDattourDAL();
            return dtDAL.Get(cri.Criter, 1, number,
            tbDattourColloumn.madattour.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }

}
